package com.stu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.time.LocalDate;
import java.util.Date;

/**
 * @projectName: learn_used_code
 * @packageName: com.stu.config
 * @className: com.stu.config-> SwaggerConfig
 * @createDate: 2021-12-02 16:36
 * @author: ZhangSheng
 * @version: 1.0
 * @description:
 */
@Configuration
public class SwaggerConfig {





    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .license("export-word-1.0")
                //文档标题
                .title("VMWARE-API文档")
                //文档描述
                .description("VMWARE-API文档，仅供学习参考使用")
                //文档版本
                .version("1.0")
                //作者及联系方式
                .contact(new Contact("zhangs", "", "2647665953@qq.com"))
                .build();
    }

    @Bean
    public Docket customImplementation(){
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.stu.controller"))
                .build()
                .directModelSubstitute(LocalDate.class, String.class)
                .directModelSubstitute(Date.class, String.class)
                .genericModelSubstitutes(ResponseEntity.class)
                .apiInfo(apiInfo());
    }


}
